﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.Entity;
using HdipCricketClub.Models;
using HdipCricketClub.ViewModels;

namespace HdipCricketClub.Models
{
    public class PlayerSeasonStatisticRepository
    {
        CricketClubEntities db = new CricketClubEntities();

        public IQueryable<PlayerSeasonStatistic> GetAllStatistics()
        {
            return db.PlayerSeasonStatistics.Include("Member").OrderBy(ps => ps.Member.last_name);
        }


        public PlayerSeasonStatistic GetPlayerStatistics(int playerId)
        {
            return db.PlayerSeasonStatistics.Where(pss => pss.player_id == playerId).Single();
        }
        
        public List<int> GetPlayerIds()
        {
            return db.PlayerSeasonStatistics.Select(pss => pss.player_id).ToList();
        }

    }
}